﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;

namespace Inspired.Euler
{
    public static class Problem022
    {
        static void Main()
        {
            //var test = "COLIN".Sum(c => (int)c - 64);
            Regex.Matches(File.ReadAllText(@"..\..\Data\names.txt"), @"""(?<name>.*?)"",?")
                .OfType<Match>()
                .OrderBy(m => m.Groups["name"].Value)
                .Select (m => m.Groups["name"].Value)
                .Select ((name, index) => (index+1) * name.Sum(c => (int)c - 64))
                .Sum()
                .DisplayAndPause();
        }
    }
}
